package ch.phovoz.tlog.listener;

import controller.DatabaseController;
import ch.phovoz.tlog.DataTraining;
import ch.phovoz.tlog.InfoObject;
import ch.phovoz.tlog.TrainingActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Spinner;
import android.widget.Toast;

public class TrainingSpinnerListener implements OnItemSelectedListener{
	TrainingActivity tActivity;
	Spinner spinner;
	private InfoObject infoobject;
	public TrainingSpinnerListener(TrainingActivity tActivity){
		infoobject=InfoObject.getInfoObject();
		this.tActivity=tActivity;
		
	}
	public void onItemSelected(AdapterView<?> parent, View view, int pos,
			long id) {
		DatabaseController dbc = new DatabaseController(tActivity);
		
		String sExersice= parent.getItemAtPosition(pos).toString();
		Integer poss = (Integer)pos;
		//tActivity.setCurrentExersice(sExersice);
		DataTraining.currentExersice=sExersice;
		//Toast.makeText(parent.getContext(), poss.toString(), Toast.LENGTH_LONG).show();
		infoobject.setCurrentExersice(pos);
		Toast.makeText(parent.getContext(), dbc.getExersice(infoobject.getCurrentExersice()), Toast.LENGTH_LONG).show();
		
	}

	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		
	}

}
